package com.google.gwt.sample.stockwatcher.client;

import com.google.gwt.i18n.client.NumberFormat;

public class StockPrice implements Comparable<StockPrice>{
	private String symbol;
	private double price;
	private double change;

	public StockPrice() {
	}

	public StockPrice(String symbol, double price, double change) {
		this.symbol = symbol;
		this.price = price;
		this.change = change;
	}
	
	public String toString(){
		String strPrice = NumberFormat.getFormat("#,##0.00").format(price);
		String strChange = NumberFormat.getFormat("#,##0.00").format(change);
		return "symbol = "+symbol+" Price = "+strPrice+" change = "+strChange;
	}

	public String getSymbol() {
		return this.symbol;
	}

	public double getPrice() {
		return this.price;
	}

	public double getChange() {
		return this.change;
	}

	public double getChangePercent() {
		return 100.0 * this.change / this.price;
	}

	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public void setChange(double change) {
		this.change = change;
	}

	@Override
	public int compareTo(StockPrice sp) {
				
		if (this.price > sp.getPrice()){
			return 1;
		}
		if (this.price < sp.getPrice()){
			return -1;
		}
		return 0;
	}

	
}
